/*常量*/
var CONSTANT = {
	DATA_TABLES : {
		DEFAULT_OPTION : { // DataTables初始化选项
			"processing" : true, // 隐藏加载提示,自行处理
			"bServerSide" : true,
			"bStateSave":true,//保存状态到cookie
			"bFilter" : false,// 去掉搜索框// sort, etc) in
			"searching" : false,// 禁用表格内搜索
			"lengthMenu" : [5, 10 ],
			"pageLength" : 5,
			"displayLength" : 5,
			'autoWidth' : true,
			"language" : {
				"processing" : "处理中...",
				"lengthMenu" : "每页 _MENU_ 项",
				"zeroRecords" : "没有匹配结果",
				"info" : "总共_PAGES_ 页，显示第_START_ 到第 _END_ ，筛选之后得到 _TOTAL_ 条，初始_MAX_ 条 ",
				"infoEmpty" : "当前显示第 0 至 0 项，共 0 项",
				"infoFiltered" : "(由 _MAX_ 项结果过滤)",
				"infoPostFix" : "",
				"search" : "搜索:",
				"url" : "",
				"emptyTable" : "表中数据为空",
				"loadingRecords" : "载入中...",
				"infoThousands" : ",",
				"paginate" : {// 分页的样式文本内容。
					"previous" : "上一页",
					"next" : "下一页",
					"first" : "第一页",
					"last" : "最后一页",
					"jump" : "跳转",
				},
				"aria" : {
					"sortAscending" : ": 以升序排列此列",
					"sortDescending" : ": 以降序排列此列"
				}
			}

		},
		CELL_CHECKBOX : { // 复选框单元格
			// 复选框单元格
			"className" : "td-checkbox",
			"orderable" : false,
			"data" : "id",
			"width" : "30px",
			"render" : function(data, type, row, meta) {
				return '<input type="checkbox" value=' + data + ' class="iCheck">';
			}
		}

	}
};


function openWindow(url,title,width,height) {
 	art.dialog.open(url, {
		title : title,
		lock : true, //锁屏
		background : "#333333", // 背景色
		width : width,
		height : height }); 
}
//通用弹出提示框 
function showTip(title,content){
	var tipHtml="<div class='modal fade' id='TipModal' tabindex='-1' role='dialog' aria-labelledby='myModalLabel' aria-hidden='true'>"
	    +"<div class='modal-dialog'> <div class='modal-content'> <div class='modal-header'>"
	   +" <button type='button' class='close' data-dismiss='modal' aria-hidden='true'>&times;</button>"
		   +"<h4 class='modal-title' id='myModalLabel'>"+title+"</h4>"
			   +"</div>"
				   +"<div class='modal-body'>"+content+"</div>"
					   +"<div class='modal-footer'>"
						   +"<button type='button' class='btn btn-default' data-dismiss='modal'>关闭</button>"
								   +"</div></div></div></div>";
	$("body").append(tipHtml);
	$('#TipModal').modal();
	//关闭时移除mode层
	$('#TipModal').on('hidden.bs.modal', function () {
		$('#TipModal').remove();
		});
}
//通用弹出提示框2
function showMsg(msg){
	bootbox.alert(msg);    
}
//通用确认框
function showConfirm(title,msg){
	  bootbox.dialog({
          message: msg,
          title: title,
          buttons: {
            success: {
              label: "确定!",
              className: "green",
              callback: function() {
              
              }
            },
            danger: {
              label: "取消",
              className: "red",
              callback: function() {
                 
              }
            } 
          }
      });
}
//将表单序列化成json 字符串
$.fn.serializeObject = function(){
 var obj = {};
 var count = 0;
 $.each( this.serializeArray(), function(i,o){
     var n = o.name, v = o.value;
     count++;
     obj[n] = obj[n] === undefined ? v
     : $.isArray( obj[n] ) ? obj[n].concat( v )
     : [ obj[n], v ];
 });
 obj.nameCounts = count + "";//表单name个数
 return JSON.stringify(obj);
};